package com.originalpoint.origin_server.controller;

import com.originalpoint.origin_server.pojo.Dto.MerchatOrderQueryDto;
import com.originalpoint.origin_server.pojo.Orders;
import com.originalpoint.origin_server.service.MerchatOrdersService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/MerchatOrders")
public class MerchatOrdersController {

    @Autowired
    private MerchatOrdersService merchatOrdersService;

    @ApiOperation(value  = "分页查询订单信息")
    @PostMapping("/select")
    public List<Orders> findMerchatOrdersById(MerchatOrderQueryDto merchatOrderQueryDto){
        List<Orders> ordersList = merchatOrdersService.findMerchatOrdersById(merchatOrderQueryDto);
        return ordersList;
    }
    @ApiOperation(value  = "根据id更新订单表信息")
    @PostMapping("/update")
    public Map updateMerchatOrders(@RequestBody Orders orders){
        System.out.println(orders.toString());
        merchatOrdersService.updateMerchatOrders(orders);

        Map map=new HashMap<>();
        map.put("msg","操作成功");
        return map;
    }
}
